﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Silverlight_Client.Commands_Utils;

namespace Silverlight_Client.ViewModels
{
    public class SelectedCategoryDetailsVM : IViewModelBase
    {
        #region Fields

        private String _body, _category, _publicationdate, _title, _imagesource;
        private String _linkpath;
        private ICommand _linkcmd;

        #endregion

        #region Properties

        public String   Body
        {
            get { return _body; }
            set
            {
                if (_body == value) return;
                _body = value;
                RaisePropertyChanged("Body");
            }
        }
        public String   Category
        {
            get { return _category; }
            set
            {
                if (_category == value) return;
                _category = value;
                RaisePropertyChanged("Category");
            }
        }
        public String   PublicationDate
        {
            get { return _publicationdate; }
            set
            {
                if (_publicationdate == value) return;
                _publicationdate = value;
                RaisePropertyChanged("PublicationDate");
            }
        }
        public String   Title
        {
            get { return _title; }
            set
            {
                if (_title == value) return;
                _title = value;
                RaisePropertyChanged("Title");
            }
        }
        public Uri      CategoryImage 
        {
            get { return new Uri(_imagesource, UriKind.Relative); }
        }

        #endregion

        #region Commands

        public ICommand LinkCmd
        {
            get { return _linkcmd; }
        }

        #endregion

        #region Commands Functions

        public void LinkFunc()
        {
        }

        #endregion

        #region Functions

        private void SetLinkPath()
        {
            switch (_category)
            {
                case "News":
                    _imagesource = "/Silverlight_Client;component/Images/news.png";
                    break;
                case "Blog":
                    _imagesource = "/Silverlight_Client;component/Images/blog.png";
                    break;
                case "Charm":
                    _imagesource = "/Silverlight_Client;component/Images/charm.png";
                    break;
                case "Various":
                    _imagesource = "/Silverlight_Client;component/Images/various.png";
                    break;
                case "Economy":
                    _imagesource = "/Silverlight_Client;component/Images/economy.png";
                    break;
                case "High-Tech":
                    _imagesource = "/Silverlight_Client;component/Images/hightech.png";
                    break;
                case "Media":
                    _imagesource = "/Silverlight_Client;component/Images/media.png";
                    break;
                case "Recreation":
                    _imagesource = "/Silverlight_Client;component/Images/recreation.png";
                    break;
                case "Sport":
                    _imagesource = "/Silverlight_Client;component/Images/sport.png";
                    break;
            }
        }

        #endregion

        #region Ctor

        public SelectedCategoryDetailsVM(String body, String category, String publicationdate, String title, String linkpath)
        {
            _body = body;
            _category = category;
            _publicationdate = publicationdate;
            _title = title;
            _linkpath = linkpath;
            _imagesource = String.Empty;
            this.SetLinkPath();
            _linkcmd = new RelayCommand(LinkFunc) { IsEnabled = true };
        }

        #endregion
    }
}
